import React from 'react'
import golbalContext from '../store'
export default class Car1 extends React.Component {
	state = {
		name: '',
		age: 0
	}
	render() {
		const { name, age } = this.state
		return (
			<div>
				<golbalContext.Consumer>
					{
						value => {
							console.log(value);

							return (
								<div>
									<input type="text" value={name} onChange={(e) => this.setState({ name: e.target.value })} />
									<input type="text" value={age} onChange={(e) => this.setState({ age: e.target.value })} />
									<button onClick={() => value.addList({ name, age })}>添加</button>
								</div>
							)
						}
					}
				</golbalContext.Consumer>
			</div >
		)
	}
}